In JDK 1.4, the NIO package is added, which is aimed at improving the IO speed. However, we all know that with the NIO package added, the old Io package is actually overwritten. Even if the NIO package is not displayed, You can obviously feel the speed improvement.
In addition, many people only know the inputstream or outputstream of the buffer when using the IO package, and the speed will be faster.
So, is there a gap in speed between the above? What is the gap? We will perform an I/O operation
;Importjava.io.IOException;ImportJava.io.PrintWriter;ImportJava.io.StringReader; Public classBufferedinputfile {//1. Buffered input file Public StaticString read (string filename)throwsioexception{//BufferedReader is designed to improve performanceBufferedReader in =NewBufferedReader (Newfilereader (filename)); String s; StringBuilder SB=NewStringBuilder (); while((S=in.readline ())! =NULL) Sb.append (s); Sb.append ("\ n");//ReadLine has deleted the line breakIn.close (); returnsb.to
: Buffer3) printstream: produce formatted output2.2.4 character-oriented outputstream Encapsulation1) bufferedwrite: corresponds to bufferedoutstream2) printwrite: corresponds to printstream3. randomaccessfile1) You can use the randomaccessfile object to read and write files.2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write3) You can directly jump to the specified position in the file.
4. An example of an I/O Applicat
types (such as int and char) to stream.2) bufferedoutstream: Buffer3) printstream: produce formatted output2.2.4 character-oriented outputstream Encapsulation1) bufferedwrite: corresponds2) printwrite: corresponds3. randomaccessfile1) You can use the randomaccessfile object to read and write files.2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write3) You can directly jump to the specified position in the file.4. An exa
) bufferedoutstream: Buffer3) printstream: produce formatted output2.2.4 character-oriented outputstream Encapsulation1) bufferedwrite: corresponds2) printwrite: corresponds3. randomaccessfile1) You can use the randomaccessfile object to read and write files.2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write3) You can directly jump to the specified position in the file.4. An example of an I/O ApplicationImport java. Io
outputstream
1) dataioutstream: outputs basic data types (such as int and char) to stream.
2) bufferedoutstream: Buffer
3) printstream: produce formatted output
2.2.4 character-oriented outputstream Encapsulation
1) bufferedwrite: corresponds
2) printwrite: corresponds
3. randomaccessfile
1) You can use the randomaccessfile object to read and write files.
2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write
3)
) bufferedoutstream: Buffer3) printstream: produce formatted output2.2.4 character-oriented outputstream Encapsulation1) bufferedwrite: corresponds2) printwrite: corresponds3. randomaccessfile1) You can use the randomaccessfile object to read and write files.2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write3) You can directly jump to the specified position in the file.4. An example of an I/O ApplicationImport java. Io
and char) to stream.2) bufferedoutstream: Buffer3) printstream: produce formatted output2.2.4 character-oriented outputstream Encapsulation1) bufferedwrite: corresponds2) printwrite: corresponds3. randomaccessfile1) You can use the randomaccessfile object to read and write files.2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write3) You can directly jump to the specified position in the file.4. An example of an I/O Appl
types (such as int and char) to stream.
2) bufferedoutstream: Buffer
3) printstream: produce formatted output
2.2.4 character-oriented outputstream Encapsulation
1) bufferedwrite: corresponds
2) printwrite: corresponds
3. randomaccessfile
1) You can use the randomaccessfile object to read and write files.
2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write
3) You can directly jump to the specified position in the file.
types (such as int and char) to stream.
2) bufferedoutstream: Buffer
3) printstream: produce formatted output
2.2.4 character-oriented outputstream Encapsulation
1) bufferedwrite: corresponds
2) printwrite: corresponds
3. randomaccessfile
1) You can use the randomaccessfile object to read and write files.
2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write
3) You can directly jump to the specified position in the file.
outputstream1) dataioutstream: outputs basic data types (INT, Char, etc.) to stream. 2) bufferedoutstream: Use buffer 3) printstream: Generate formatted output 2.2.4 used to encapsulate character-oriented outputstream1) bufferedwrite: corresponds to 2) printwrite: corresponds to 3. randomaccessfile1) You can use the randomaccessfile object to perform read and write operations on the file. 2) when an object is generated, you can specify the nature of the file to be opened: R, read-only; W, write
you use BufferedReader when using readLine (), use DataInputStream
2) BufferedReader: corresponds to BufferedInputStream
3) LineNumberReader: corresponds to LineNumberInputStream
4) PushBackReader: corresponds to PushbackInputStream
2.3FilterOutStream types
2.2.3 encapsulate byte-oriented OutputStream
1) DataIOutStream: outputs basic data types (such as int and char) to stream.
2) BufferedOutStream: Buffer
3) PrintStream: produce formatted output
2.2.4 character-oriented OutputStream Encapsulat
: // www.python.org ']
Def test (url ):
Return urllib2.urlopen (url). read ()
Def testIO (nbFutures ):
Ts = time. time ()
Map (test, urls * nbFutures)
Span = time. time ()-ts
Print "time spend", span
TestIO (10)
I will not list the code in different concurrent libraries because it is similar. You can refer to the computing-intensive code for reference.
Through tests, we can find that the use of m
environment variables: Public Static void Main (string[] args) { system.getproperties (). List (System.out);}Look at the output of all the information, a bit long:1--Listing properties--2Java.runtime.name=Java (TM) SE Runtime Environment3Sun.boot.library.path=E:\MyEclipse10\Common\binary\com.sun ....4java.vm.version=11.3-B025Java.vm.vendor=Sun Microsystems Inc.6Java.vendor.url=http://java.sun.com/7Path.separator=;8Java.vm.name=java HotSpot (TM) 64-Bit Server VM9file.encoding.pkg=Sun.ioTenuse
: Using buffers3) PrintStream: produces formatted outputThe 2.2.4 is used to encapsulate character-oriented OutputStream1) Bufferedwrite: with corresponding2) Printwrite: with corresponding3. Randomaccessfile1) Read and write files can be completed by Randomaccessfile object2) When generating an object, you can indicate the nature of the file to be opened: R, read only, W, write only, rw readable and writable3) You can jump directly to the location specified in the file4. An example of an I/O ap
.gz (11,670,726 bytes)· Orion_solaris64_sparc.gz (898,929 bytes)· Orion_solaris_x8664.gz (655,975 bytes)· Orion_linux_em64t.gz (767,380 bytes)· Orion10.2_linux.gz (630,354 bytes)· Orion10. 2_windows.msi (7,865,856 bytes)· Users guideAs you can see, this software already supports multiple OS environments. Unfortunately,OracleIt does not provide service support for the software. However, this does not affect the normal use of the software. From my test results, the software is really a good storag
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.